Nextcloud

#cloud #gmail #opensource

Regain control over your data. Remote collaboration made easy

I dropped Google Drive harder than a DJ with a fresh new crate of tracks. I even brought on some friends and family


connections

installation

  1. note that I use an external drive. You must set up your other drive first.
  2. Docker compose.yml
version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-read-only-compressed=OFF
    volumes:
      - /home/<username>/docker/nextcloud/db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=<password09>
      - MYSQL_PASSWORD=<password09>
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud:25 # USE current version number, increment by one when upgrading
    restart: always
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - /home/<username>/docker/nextcloud/html:/var/www/html
      - /home/<username>/docker/nextcloud/html/apps:/var/www/html/custom_apps 
      - /home/<username>/docker/nextcloud/html/config:/var/www/html/config 
      - /mnt/<externalDrive>/nextcloud/data:/var/www/html/data
    environment:
      - MYSQL_PASSWORD=<password09>
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db

How to Update

Error

Don't use nextcloud:latest as the image.
UPDATE ONE MAJOR VERSION AT A TIME
23 -> 24 👍
23 -> 25 🚫


Gmail SMTP server

Nextcloud needs a way to send password resets / notifications / alerts. So I've hooked it up with gmail's SMTP server using an google app password.


Troubleshooting

Upgraded 2 versions up on accident

Turn off Maintenance mode

via config/config.php source

recover old ./version.php

  1. restore /version.php from backup into the container
  2. run a manual update via
  3. docker-compose exec --user www-data nextcloud php occ -vvv upgrade
  4. docker-compose exec --user www-data nextcloud php occ maintenance:mode --off. (or with method above)

That got me back to a running v19.
From there I could then pull the v20 docker image and run the upgrade to v20 using the same two commands.
source

If you don't make backups then you could possibly edit the container's html/version.php. Gotta thank Duplicati for saving my behind

Upgrading to AIO (All In One)

Will get to this eventually, but for now I'm sticking with the regular nextcloud:latest docker container deployment

Fix Security & Setup Warnings

If you've been upgrading Nextcloud from an older version (in my case 23), I'm sure you'll find a list of warnings in the admin dashboard found at https://YOUR_NEXTCLOUD_DOMAIN/settings/admin/overview

config updates

Warning from Nextcloud

Server has no maintenance window start time configured. This means resource intensive daily background jobs will also be executed during your main usage time. We recommend to set it to a time of low usage, so users are less impacted by the load caused from these heavy tasks. For more details see the documentation ↗.

Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective ISO 3166-1 code of the region to your config file. For more details see the documentation ↗.

sudo nano ./nextcloud/html/config/config.php

## Add this to top inside the first `array(`
'maintenance_window_start' => 1, # period between 1am 5am UTC
'default_phone_region' => 1974, # United States code

What it will look like

<?php
$CONFIG = array (
  'maintenance_window_start' => 1,
  'default_phone_region' => 1974,
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
...

Mimetype Repair

Warning from Nextcloud

One or more mimetype migrations are available. Occasionally new mimetypes are added to better handle certain file types. Migrating the mimetypes take a long time on larger instances so this is not done automatically during upgrades. Use the command occ maintenance:repair --include-expensive to perform the migrations.

This is how I ran it with nextcloud-app-1 being the exact name of my container

docker exec -it -u 33 nextcloud-app-1 /var/www/html/occ  maintenance:repair --include-expensive

fix missing db indexes

Warning from Nextcloud

The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running "occ db:add-missing-indices" those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster. (long list of missing stuff)

docker exec -it -u 33 nextcloud-app-1 /var/www/html/occ db:add-missing-indices

enhance memcache file locking

Nextcloud

The database is used for transactional file locking. To enhance performance, please configure memcache, if available. For more details see the documentation ↗.

This looks like this is for servers with heavy multi user activity. I'll get back to this later as I could see some benefit to setting this up anyway for myself

To use a memcache with Transactional File Locking, you must install the Redis server and corresponding PHP module.

If you want to configure Redis to listen on an Unix socket (which is recommended if Redis is running on the same system as Nextcloud) use this example config.php configuration:

'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
     'host' => '/var/run/redis/redis.sock',
     'port' => 0,
     'timeout' => 0.0,
     'password' => '', // recommended!, if not defined no password will be used.
	),

Rescan files

If you edited any files outside of Nextcloud UI (possibly in the terminal), you will need to rescan files to update Nextcloud's database

docker exec -it -u 33 nextcloud-app-1 /var/www/html/occ  files:scan --all
docker exec -it -u 33 nextcloud-app-1 /var/www/html/occ  files:cleanup
## Go to the nextcloud folder (Ex. /var/www/nextcloud) where the **occ** exists.

docker exec -it -u 33 nextcloud-app-1 /var/www/html/occ maintenance:mode --on

docker exec -it -u 33 nextcloud-app-1 redis-cli --askpass -s /var/run/redis/redis.sock flushall
Password can be found in nextcloud_folder/config/config.php

docker exec -it -u 33 nextcloud-app-1 /var/www/html/occ maintenance:mode --off

docker exec -it -u 33 nextcloud-app-1 /var/www/html/occ files:scan --all

## This scans for all files within the specific user
docker exec -it -u 33 nextcloud-app-1 /var/www/html/occ files:scan-app-data

## This scans for all the shared folder or files that has been shared

Flush File Lock Cache in SQL

docker exec nextcloud-db-1 mysql nextcloud -p$MYSQL_ROOT_PASSWORD -e "SELECT * FROM oc_file_locks WHERE \`lock\`<>0;"

#todo


Credits